package fileProcessors;

import java.io.File;

/**
 * File Processors can be added to a File Selector to process Files and print
 * the output to a File
 * 
 * @author Wolfgang Gross
 *
 */
public abstract class FileProcessor {

	/*
	 * These three methods define the behaviour of the file processor
	 */
	public abstract void processFiles(File[] files, File outputDirectory, File outputFile) throws FileFormatException;

	public abstract String getDate();

	public abstract String getInformation();

	private File currentDirectory;
	private File outputFile;
	private File[] files;
	private int id;
	private static int idCounter = 0;

	private String txtProcessBtn;
	private String txtIncludeFilename;
	private String txtExcludeFilename;
	private String txtResultFilename;

	/**
	 * Creates a new FileProcessor which can be added to a FileSelector
	 */
	public FileProcessor() {
		this(null);
	}

	/**
	 * Creates a new FileProcessor which can be added to a FileSelector
	 * 
	 * @param txtProcessBtn
	 *            Text of Process Button
	 */
	public FileProcessor(String txtProcessBtn) {
		this(txtProcessBtn, null, null);
	}

	/**
	 * Creates a new FileProcessor which can be added to a FileSelector
	 * 
	 * @param txtProcessBtn
	 *            Text of Process Button. If null, "Process is displayed"
	 * @param includeFilename
	 *            preset Text of includeFilename text field
	 * @param excludeFilename
	 *            preset Text of excludeFilename text field
	 */
	public FileProcessor(String txtProcessBtn, String includeFilename, String excludeFilename) {
		this(txtProcessBtn, includeFilename, excludeFilename, null);
	}

	/**
	 * Creates a new FileProcessor which can be added to a FileSelector
	 * 
	 * @param txtProcessBtn
	 *            text of Process Button. If null, "Process is displayed"
	 * @param includeFilename
	 *            preset text of includeFilename text field
	 * @param excludeFilename
	 *            preset text of excludeFilename text field
	 * @param txtResultFilename
	 *            preset text of result text field
	 */
	public FileProcessor(String txtProcessBtn, String includeFilename, String excludeFilename, String txtResultFilename) {
		this.txtResultFilename = txtResultFilename;
		this.txtProcessBtn = txtProcessBtn;
		this.txtIncludeFilename = includeFilename;
		this.txtExcludeFilename = excludeFilename;
		this.txtResultFilename = txtResultFilename;
		this.id = idCounter;
		idCounter++;
	}

	/**
	 * Must not be overwritten by the implementing classes
	 */
	public final void processFiles() {
		processFiles(files, currentDirectory, outputFile);
	}

	public final void setOutputFile(File outputFile) {
		this.outputFile = outputFile;
	}

	public final void setFiles(File[] files) {
		this.files = files;
	}

	public final void setCurrentDirectory(File file) {
		this.currentDirectory = file;
	}

	public final int getID() {
		return this.id;
	}

	public String getTxtProcessBtn() {
		return txtProcessBtn;
	}

	public String getTxtIncludeFilename() {
		return txtIncludeFilename;
	}

	public String getTxtExcludeFilename() {
		return txtExcludeFilename;
	}

	public String getTxtResult() {
		return txtResultFilename;
	}
}
